
import { watch, ref } from 'vue'
import SensitiveWordFilter from '../../common/filter/SensitiveWordFilter'
import SensitiveWordMap from '../../common/filter/SensitiveWordMap'

export const useFilter = (words = []) => {
    let filterWords = ref(words)
    let filter = new SensitiveWordFilter(words)

    watch(filterWords, (nWords) => {
        filter.sensitiveWordMap = new SensitiveWordMap(nWords);
    })

    return { filterWords, filter }
}